/*
 * debug.c
 *
 *  Created on: 2017年7月11日
 *      Author: changruowang
 */
#include "system.h"
#include "user_bsp.h"

void R_SCI1_Serial_Send_Char(uint8_t  tx_char)
{
		while(!SCI1.SSR.BIT.TEND)//

		PORTD.PMR.BYTE |= 0x08U;
        SCI1.SCR.BIT.TIE = 0U;
        SCI1.SCR.BIT.TEIE = 0U;
        SCI1.SCR.BIT.TE = 1U;
        SCI1.TDR = tx_char;
}

void R_SCI5_Serial_Send_Char(uint8_t  tx_char)
{
		while(!SCI5.SSR.BIT.TEND)//

		PORTB.PMR.BYTE |= 0x02U;
        SCI5.SCR.BIT.TIE = 0U;
        SCI5.SCR.BIT.TEIE = 0U;
        SCI5.SCR.BIT.TE = 1U;
        SCI5.TDR = tx_char;
}

void SCI1_Printf(char *fmt,...)
{
    uint16_t i,j;
	va_list ap;
	va_start(ap,fmt);
	vsprintf((char*)send_buf,fmt,ap);
	va_end(ap);
	i=strlen((const char*)send_buf);
	for(j=0;j<i;j++)							//Ñ­»··¢ËÍÊý¾Ý
	{
		R_SCI1_Serial_Send_Char(send_buf[j]);
	}
//	R_SCI1_Serial_Send_Char();
//	R_SCI1_Serial_Send(send_buf,i);
//	sci_sendOK &= (~0X01);
}

void SCI5_Printf(char *fmt,...)
{
    uint16_t i;
	va_list ap;
	va_start(ap,fmt);
	vsprintf((char*)send_buf,fmt,ap);
	va_end(ap);
	i=strlen((const char*)send_buf);

	R_SCI5_Serial_Send(send_buf,i);
	sci_sendOK &= (~0X80);
}
